import { createApp } from 'vue';
import App from '../App.vue';
import { createRouter, createWebHistory } from 'vue-router';
import Index from '../views/Index.vue';
import BusinessList from '../views/BusinessList.vue';
import BusinessInfo from '../views/BusinessInfo.vue';
import Login from '../views/Login.vue';
import Orders from '../views/Orders.vue';
import UserAddress from '../views/UserAddress.vue';
import Payment from '../views/Payment.vue';
import OrderList from '../views/OrderList.vue';
import AddUserAddress from '../views/AddUserAddress.vue';
import EditUserAddress from '../views/EditUserAddress.vue';
import MyInfo from '../views/MyInfo.vue';
import Register from '../views/Register.vue';
import SuccessPayment from '../views/SuccessPayment.vue';
import ChangePw from '../views/ChangePw.vue';
import Remark from '../views/Remark.vue';
import Found from '../views/Found.vue';
import BusinessList2 from '../views/BusinessList2.vue';
import ChangeAvatar from '../views/ChangeAvatar.vue';
import ChangeName from '../views/ChangeName.vue';
import MyFavorites from '../views/MyFavorites.vue';
import MySearch from '../views/MySearch.vue';
import Error403 from '../components/Error403.vue';
import MyWallet from '../views/MyWallet.vue';
import TransactionDetail from '../views/TransactionDetail.vue';
import BusinessLogin from '../views/BusinessLogin.vue';
import BusinessRegister from '../views/BusinessRegister.vue';
import BusinessManage from '../views/BusinessManage.vue';
import FoodManage from '../views/FoodManage.vue';
import BusinessWallet from '../views/BusinessWallet.vue';
import PointMall from '../views/PointMall.vue';
import BusinessInfoEdit from '../views/BusinessInfoEdit.vue';


const routes = [
    { path: '/', name: 'Home', component: Index },
    { path: '/index', name: 'Index', component: Index },
    { path: '/businessList', name: 'BusinessList', component: BusinessList },
    { path: '/businessInfo', name: 'BusinessInfo', component: BusinessInfo },
    { path: '/login', name: 'Login', component: Login },
    { path: '/orders', name: 'Orders', component: Orders },
    { path: '/userAddress', name: 'UserAddress', component: UserAddress },
    { path: '/payment', name: 'Payment', component: Payment },
    { path: '/orderList', name: 'OrderList', component: OrderList },
    { path: '/addUserAddress', name: 'AddUserAddress', component: AddUserAddress },
    { path: '/editUserAddress', name: 'EditUserAddress', component: EditUserAddress },
    { path: '/register', name: 'Register', component: Register },
	 { path: '/myInfo', name: 'MyInfo', component: MyInfo },
	{ path: '/successPayment', name: 'SuccessPayment', component: SuccessPayment },
	{ path: '/changePw', name: 'ChangePw', component: ChangePw },
	{ path: '/remark', name: 'Remark', component: Remark },
	{ path: '/found', name: 'Found', component: Found },
	{ path: '/businessList2', name: 'BusinessList2', component: BusinessList2 },
	{ path: '/changeAvatar', name: 'ChangeAvatar', component: ChangeAvatar },
	{ path: '/changeName', name: 'ChangeName', component: ChangeName },
	{ path: '/myFavorites', name: 'MyFavorites', component: MyFavorites },
	{ path: '/mySearch', name: 'MySearch', component: MySearch },
	{ path: '/error403', name: 'Error403', component: Error403 },
	{ path: '/myWallet', name: 'MyWallet', component: MyWallet },
	{ path: '/transactionDetail', name: 'TransactionDetail', component: TransactionDetail },
	{ path: '/businessLogin', name: 'BusinessLogin', component: BusinessLogin },
	{ path: '/businessRegister', name: 'BusinessRegister', component: BusinessRegister },
	{ path: '/businessManage', name: 'BusinessManage', component: BusinessManage },
	{ path: '/foodManage', name: 'FoodManage', component: FoodManage },
	{ path: '/businessWallet', name: 'BusinessWallet', component: BusinessWallet },
	{ path: '/pointMall', name: 'PointMall', component: PointMall },
	{ path: '/businessInfoEdit', name: 'BusinessInfoEdit', component: BusinessInfoEdit }
];

// 解决重复路由报异常问题
const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
});

createApp(App).use(router).mount('#app');

const originalPush = router.push;
router.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
};

export default router;